warframefandomcom_it-20200215-history
Modulo:Cost
This will eventually contain data for various weapons --For use in automating assorted wiki functions and to reduce the number of updates needed --But starting with Melee Stances local p = {} local WeaponModule = require( 'Module:Weapons' ) local Icon = require( "Module:Icon" ) local Shared = require( "Module:Shared" ) local Void = require( "Module:Void" ) local ResearchData = mw.loadData( "Module:Research/data" ) function p.isResearch(itemName) for i, val in pairs(ResearchData"Research") do if(val.Name ~= nil and val.Name itemName) then return true, val end end return false, nil end local function buildItemText(Item) if(Item nil) then return " " end if(Item.Type "Resource" or Item.Type nil) then return Icon._Resource(Item.Name, nil, 'x32').." "..Shared.formatnum(Item.Count) elseif(Item.Type "Item") then return Icon._Item(Item.Name, nil, 'x32').." "..Shared.formatnum(Item.Count) elseif(Item.Type "PrimePart") then return Icon._Item("Prime "..Item.Name, nil, 'x32').." "..Shared.formatnum(Item.Count) elseif(Item.Type "Weapon") then local itemWeapon = WeaponModule.getWeapon(Item.Name) if(itemWeapon.Image ~= nil) then return ' '..Shared.formatnum(Item.Count) else return "IMAGE: "..Item.Name.." "..Shared.formatnum(Item.Count) end end end function p.buildWeaponCostBox(frame) local WeaponName = frame.args ~= nil and frame.args1 or frame local Weapon = WeaponModule.getWeapon(WeaponName) if(Weapon nil) then return "ERROR: "..WeaponName.." non trovato" elseif(Weapon.Cost nil) then return "ERROR: "..WeaponName.." non ha dati riguardo ai costi" end local rowStart = '\n| rowspan="2" style="height:50px; width:50px;" |' local smallPart = '\n| style="text-align:left; padding: 0em 0.25em;" |' local lowRow = '\n| colspan="3" |' if(Weapon.Cost.Parts ~= nil) then local primeParts = {} local foundryTable = ' ' foundryTable = foundryTable..'\nLith/Meso/Neo/Axi si riferiscono alle Reliquie Voids (V) Denota le Reliquie attualmente nel Vault' end --Adding Research costs if needed local isResearch, weapRes = p.isResearch(Weapon.Name) if(isResearch) then foundryTable = foundryTable..'\n|-\n! colspan=6| Ricerca' if(weapRes.Affinity ~= nil) then foundryTable = foundryTable..' '..Icon._Affinity("Clan").." "..Shared.formatnum(weapRes.Affinity) end foundryTable = foundryTable..'\n|-'..rowStart --Adding Credit costs if(weapRes.Credits ~= nil) then foundryTable = foundryTable..Icon._Item("Credits").." "..Shared.formatnum(Weapon.Cost.Credits) else foundryTable = foundryTable..'N/A' end --Adding part costs for i=1, 4 do foundryTable = foundryTable..rowStart..buildItemText(weapRes.Resourcesi) end --Adding the time, market, and rush cost foundryTable = foundryTable..smallPart if(weapRes.Time ~= nil) then foundryTable = foundryTable.."Time: "..Weapon.Cost.Time.." hrs" else foundryTable = foundryTable..'N/A' end foundryTable = foundryTable..'\n|-'..smallPart if(weapRes.Prereq ~= nil) then foundryTable = foundryTable..'Prereq: '..weapRes.Prereq..'' else foundryTable = foundryTable..'Prereq: N/A' end --Adding notes about clan sizes foundryTable = foundryTable..'\n|-\n| colspan = 6 |' foundryTable = foundryTable..' x1 ' foundryTable = foundryTable..' x3 ' foundryTable = foundryTable..' x10 ' foundryTable = foundryTable..' x30 ' foundryTable = foundryTable..' x100' foundryTable = foundryTable..'' end foundryTable = foundryTable..'\n|} ' return foundryTable end end function p.getResourceCostRows(frame) local ResName = frame.args ~= nil and frame.args1 or frame local Weapons = WeaponModule.getWeapons(function() return true end) local result = "" for key, weap in Shared.skpairs(Weapons) do --Adding Research costs if needed local resNum = 0 local mainNum = 0 if(weap.Cost ~= nil and weap.Cost.Parts ~= nil) then for i, val in pairs(weap.Cost.Parts) do if(val.Name ResName) then mainNum = val.Count end end end local isResearch, weapRes = p.isResearch(weap.Name) if(isResearch and weapRes.Resources ~= nil) then for i, val in pairs(weapRes.Resources) do if(val.Name ResName) then resNum = val.Count end end end if(resNum > 0 or mainNum > 0) then result = result..'\n|-\n| '..weap.Name..' || '..weap.Type..' || ' if(mainNum > 0) then result = result..Shared.formatnum(mainNum) end if(resNum > 0) then result = result..' ('..Shared.formatnum(resNum)..')' end end end return result end return p